/**
*  
* @Function ES操作实体 
* @ProjectName credit-framework-common
* @PackageName com.py.credit.utils.elasticsearch
* @FileName EsQueryEntity.java    
* @Date 2018年11月5日下午4:16:06
* @Author Min DongXv
* @Copyright (c) 2018, 金电联行 All Rights Reserved.   
*   
*/  
package com.py.credit.utils.elasticsearch;

import java.io.Serializable;
import java.util.Arrays;

/**
*   
* @Function ES操作实体
* @ClassName EsQueryEntity   
* @Date 2018年11月5日 下午4:16:06   
* @Author Min DongXv
*       
*/
public class EsQueryEntity implements Serializable {

	private static final long serialVersionUID = 6136623740114763L;
	// 查询连接符 不包含-mustNot OR-should and-must
	private String queryConnector;
	// 单个字段
	private String field;
	// 字段值
	private String value;
	// 是否模糊查询
	private boolean isFuzzy;
	// 是否多字段匹配一个值
	private boolean isFieldMulit;
	// 是否单字段匹配多值
	private boolean isValueMulit;
	// 多字段匹配一个值时传入字段的值
	private String[] fields;

	public EsQueryEntity() {
	}

	/**
	 * @function 多字段单值模糊搜索构造器
	 * @param queryConnector
	 * @param value
	 * @param fields
	 */
	public EsQueryEntity(String queryConnector, String[] fields, String value) {
		this.queryConnector = queryConnector;
		this.value = value;
		this.fields = fields;
		this.isFieldMulit = true;
		this.isValueMulit = false;
		this.isFuzzy = true;
	}

	/**
	 * @function 单字段单值模糊搜索构造器
	 * @param queryConnector
	 * @param field
	 * @param value
	 */
	public EsQueryEntity(String queryConnector, String field, String value) {
		this.queryConnector = queryConnector;
		this.field = field;
		this.value = value;
		this.isFieldMulit = false;
		this.isValueMulit = false;
		this.isFuzzy = true;
	}

	/**
	 * @function 单字段多值精确搜索构造器(暂无直接的多字段多值构造器，可以用多个单字段多值构造器组成)
	 * @param queryConnector
	 * @param field
	 *            字段
	 * @param value
	 *            多值以，分隔
	 * @param isFuzzy
	 *            是否模糊搜索
	 */
	public EsQueryEntity(String queryConnector, String field, String value, boolean isFuzzy) {
		this.queryConnector = queryConnector;
		this.field = field;
		this.value = value;
		this.isFuzzy = false;
		this.isFieldMulit = false;
		this.isValueMulit = true;
	}

	/**
	 * @return the queryConnector
	 */
	public String getQueryConnector() {
		return queryConnector;
	}

	/**
	 * @param queryConnector
	 *            the queryConnector to set
	 */
	public void setQueryConnector(String queryConnector) {
		this.queryConnector = queryConnector;
	}

	/**
	 * @return the field
	 */
	public String getField() {
		return field;
	}

	/**
	 * @param field
	 *            the field to set
	 */
	public void setField(String field) {
		this.field = field;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value
	 *            the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * @return the isFuzzy
	 */
	public boolean isFuzzy() {
		return isFuzzy;
	}

	/**
	 * @param isFuzzy
	 *            the isFuzzy to set
	 */
	public void setFuzzy(boolean isFuzzy) {
		this.isFuzzy = isFuzzy;
	}

	/**
	 * @return the fields
	 */
	public String[] getFields() {
		return fields;
	}

	/**
	 * @param fields
	 *            the fields to set
	 */
	public void setFields(String[] fields) {
		this.fields = fields;
	}

	/**
	 * @return the isFieldMulit
	 */
	public boolean isFieldMulit() {
		return isFieldMulit;
	}

	/**
	 * @param isFieldMulit
	 *            the isFieldMulit to set
	 */
	public void setFieldMulit(boolean isFieldMulit) {
		this.isFieldMulit = isFieldMulit;
	}

	/**
	 * @return the isValueMulit
	 */
	public boolean isValueMulit() {
		return isValueMulit;
	}

	/**
	 * @param isValueMulit
	 *            the isValueMulit to set
	 */
	public void setValueMulit(boolean isValueMulit) {
		this.isValueMulit = isValueMulit;
	}

	@Override
	public String toString() {
		return "EsQueryEntity [queryConnector=" + queryConnector + ", field=" + field + ", value=" + value
				+ ", isFuzzy=" + isFuzzy + ", isFieldMulit=" + isFieldMulit + ", isValueMulit=" + isValueMulit
				+ ", fields=" + Arrays.toString(fields) + "]";
	}
}
